package com.hzhq.contract.convert;

import com.hzhq.contract.bean.dto.DepartDTO;
import com.hzhq.contract.bean.entity.Depart;
import com.hzhq.contract.bean.vo.DepartVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author: hzhq1255
 * @mail: hzhq1255@163.com
 * @date: 2021/4/15 0:32
 * @desc:
 */
@Mapper
public interface DepartConvertBasic {

    DepartConvertBasic INSTANCE = Mappers.getMapper(DepartConvertBasic.class);

    DepartDTO poToDto(Depart source);

    Depart dtoToPo(DepartDTO source);

    @Mappings({
            @Mapping(target = "departId", expression = "java(com.hzhq.contract.util.ConvertUtil.objectIdToString(source.getDepartId()))")
    })
    DepartVO dtoToVo(DepartDTO source);

    @Mappings(value = {
            @Mapping(target = "departId", expression = "java(com.hzhq.contract.util.ConvertUtil.stringToObjectId(source.getDepartId()))"),
            @Mapping(target = "deleted", expression = "java(com.hzhq.contract.status.DefaultValue.NOT_DELETED)")
    })
    DepartDTO voToDto(DepartVO source);

}
